#!/usr/bin/python
import Entity
import pygame
import game_engine.GameEngine
import effects.GrowEffect


# Entity which makes player grow and then self destructs
class GrowEntity(Entity.Entity):


    # Obvious
    def __init__(self, name):
        super(GrowEntity, self).__init__(name)
        self.m_pickedUp = False
        self.m_sizeChange = 2
        self.m_durationms = 5000
        # Set this to false to pickup
        self.m_useImmediately = True


    # Called when an entity attempts to interact with this entity by bumping into it
    def interactBumped(self, otherEntity):
        # If already used, skip
        if self.m_pickedUp:
            return False

        # Handle use or pickup
        if self.m_useImmediately:
            self.use(otherEntity)
        else:
            otherEntity.addToInventory(self)

        # Either way, we're gone from the world
        game_engine.GameEngine.getGameEngine().getEntityManager().unregisterEntity(self)

        # Note used
        self.m_pickedUp = True

        return True

    # Called to use this entity
    def use(self, user):
        # Attach new effect - 5 seconds of 2 growth
        effect = effects.GrowEffect.GrowEffect(user, self.m_sizeChange, self.m_durationms)
        user.addEffect(effect)
        

